Imports System.Text

Public Class CSScriptedTORenderEngine
    Inherits CSAbstractRenderEngine

    Public Sub New(ByVal u As UpdateProgress, ByVal s As UpdateStatus)
        MyBase.New(u, s, GetType(Script))
    End Sub

    Protected Overrides Function FormatFilename(ByVal tableName As String) As String
        Return tableName & "TO"
    End Function

    Protected Overrides Function RenderPrefix(ByVal t As Table) As String
        Dim sb As New StringBuilder
        sb = sb.Append("using pixolut.BizBlox;").Append(vbCrLf).Append(vbCrLf)
        sb = sb.Append("public class ").Append(FormatFilename(t.TableName))
        sb = sb.Append(" : DOTO").Append(vbCrLf)
        sb = sb.Append("{").Append(vbCrLf)
        Return sb.ToString()
    End Function

    Protected Overrides Function RenderPostfix(ByVal t As Table) As String
        Dim sb As New StringBuilder
        sb = sb.Append(vbCrLf)
        sb = sb.Append("}").Append(vbCrLf)
        Return sb.ToString()
    End Function

    Protected Overrides Function RenderColumn(ByVal t As Table, ByVal index As Integer) As String
        Dim sb As New StringBuilder
        sb = sb.Append(vbCrLf)
        sb = sb.Append("    private ").Append(t(index).DataType).Append(" m_").Append(t(index).ColumnName).Append(";").Append(vbCrLf)
        sb = sb.Append("    public ").Append(t(index).DataType).Append(" ").Append(t(index).ColumnName).Append("{").Append(vbCrLf)
        sb = sb.Append("        get {").Append(vbCrLf)
        sb = sb.Append("            return m_").Append(t(index).ColumnName).Append(";").Append(vbCrLf)
        sb = sb.Append("        }").Append(vbCrLf)
        sb = sb.Append("        set {").Append(vbCrLf)
        sb = sb.Append("            m_").Append(t(index).ColumnName).Append(" = value;").Append(vbCrLf)
        sb = sb.Append("        }").Append(vbCrLf)
        sb = sb.Append("    }").Append(vbCrLf).Append(vbCrLf)
        Return sb.ToString()
    End Function

    Protected Overrides Function RenderForeignColumn(ByVal t As Table, ByVal index As Integer) As String
        Return ""
    End Function

    Protected Overrides Function RenderElements(ByVal t As Table) As String
        Return ""
    End Function
End Class
